package pt.iul.poo.weapon;

import java.awt.Color;
import java.awt.geom.Line2D;
import java.util.ArrayList;
import java.util.LinkedList;

import pt.iul.poo.balloons.Balloon;
import pt.iul.poo.game.Player;
import pt.iul.poo.image.properties.GameWindowInterface;
import pt.iul.poo.monkeys.Monkey;
import pt.iul.poo.shapes.SimpleShape;

public abstract class Weapons {
	private int damage;
	private Color color;
	private int timeout;

	public Weapons(Color color, int damage) {
		this.color = color;
		this.damage = damage;
	}

	public void shoot(Balloon balloon, GameWindowInterface window,
			Monkey monkey, LinkedList<SimpleShape> listShapes) {
		SimpleShape s = new SimpleShape(new Line2D.Double(monkey.getPosition()
				.getX() + monkey.getDimension().width / 2, monkey.getPosition()
				.getY() + monkey.getDimension().height / 2, balloon
				.getPosition().getX() + balloon.getDimension().width / 2,
				balloon.getPosition().getY() + balloon.getDimension().height
						/ 2), color, 100);
		listShapes.add(s);
		window.getDisplayer().add(s);
		window.getDisplayer().refresh();
	}

	public void removeLife(Balloon balloon, LinkedList<Balloon> balloonsList,
			Player player, ArrayList<Balloon> ballonsToRemove) {

		if (balloon.getHealth() - damage <= 0) {
			ballonsToRemove.add(balloon);
			
		} else {
			balloon.setHealth(balloon.getHealth() - damage);
			System.out.println("REMOVI VIDA");
		}
	}

	public int getDamage() {
		return damage;
	}

	public void setDamage(int damage) {
		this.damage = damage;
	}

	public Color getColor() {
		return color;
	}

	public void setColor(Color color) {
		this.color = color;
	}

	public int getTimeout() {
		return timeout;
	}

	public void setTimeout(int timeout) {
		this.timeout = timeout;
	}

}
